<?php
session_start();

if(!empty($_REQUEST['hidUpdSet']))
{
     $mail=$_REQUEST['admin_email'];
	 //$paypal=$_REQUEST['admin_paypal'];
	
     $sql_addusr="UPDATE tbl_settings set admin_email='$mail'
			 where setting_id='1'";
	 $rst_addusr=mysql_query($sql_addusr);
	 if($rst_addusr) {
	 	$smsg="General settings updated Successfully";   
	}
	else {
		$smsg="Error occured on updating genereal settings.";
	}
}


$sql_show="SELECT * FROM tbl_settings where setting_id='1'";
$rst_show=mysql_query($sql_show);
$row_show=mysql_fetch_array($rst_show);
$email=$row_show['admin_email'];
//$payEmail=$row_show['paypal'];
 ?>
<script type="text/javascript">

function validateSettings()
{
	var email=document.getElementById("admin_email");
	//var payemail=document.getElementById("admin_paypal");
	if(email.value=="")
	{
		alert("Please Enter Admin Email");		
		email.focus();
		return false;
	}
	/*
	if(payemail.value=="")
	{
		alert("Please Enter Paypal Email Address");		
		payemail.focus();
		return false;
	}*/
	
	if(email.value != '')
	 {
		 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.value))
		{
		  ///  valid email  ////
		  var err=1;
		}
		else 
		{
		alert("Invalid E-mail Address! Please re-enter.");
		var err=0;
		email.focus();
		return false;
		}
	 }
	 
	 /*
	 if(payemail.value != '')
	 {
		 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(payemail.value))
		{
		  ///  valid email  ////
		  var err=1;
		}
		else 
		{
		alert("Invalid E-mail Address! Please re-enter.");
		var err=0;
		payemail.focus();
		return false;
		}
	 }*/
	 	 
	 if(err==1) return true;
}

function updateSettings()
{
	var x=document.getElementById("form1");
	document.getElementById("hidUpdSet").value="Submit";
	if(validateSettings())	 
	 x.submit();
}


</script> 
<form name="form1"  id="form1" action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="hidUpdSet" id="hidUpdSet">
<table width="100%"  border="1" cellspacing="0" class="container" >
  <tr>
    <td width="718" height="27" class="tdHeader">General Settings</td>
  </tr>
  <tr>
    <td height="577"><table width="553" border="0">
      <tr>
        <td height="30">&nbsp;</td>
        <td colspan="2" align="center">
			<?php
				  if(!empty($smsg))
					echo $smsg;
			?>						     
		</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width="78" height="32">&nbsp;</td>
        <td>Admin Email</td>
        <td><input type="text" name="admin_email" id="admin_email" value="<?php echo $email; ?>"  class="text" /></td>
        <td width="84">&nbsp;</td>
      </tr>
      <!--
	  <tr>
        <td width="78" height="32">&nbsp;</td>
        <td>Paypal Email Address </td>
        <td><input type="text" name="admin_paypal" id="admin_paypal" value="<?php echo $payEmail; ?>"  class="text" /></td>
        <td width="84">&nbsp;</td>
      </tr>
	  -->
      <tr>
        <td height="29">&nbsp;</td>
        <td colspan="2"><div align="center">
          <input type="button" name="button" value="Update" class="button" onclick="updateSettings();" />
        </div></td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</form>